Multiple Selection

The Property Grid supports multiple selected objects. For example, suppose the property grid tracks the selection in, say, a drawing program to allow users to edit shape properties such as fill or line thickness. If the drawing program supports multiple selection, you would like the property grid to allow editing of all selected items simultaneously.

To assign a multiple selection, set the PropertyGrid.SelectedObjects property, or create a MultipleObjectWrapper containing the required objects, and set PropertyGrid.SelectedObject to that MultipleObjectWrapper.

When the values of a property are the same across the selected objects, the grid displays the value and allows editing. When the values of a property are different across the selected objects, the grid displays a “multiple values” indicator and provides a button to set the value on all objects (after which it can be edited normally). You can customize the “multiple values” display by providing resources with the keys defined on the ManyEditor class, or for more extensive customization by styling or retemplating the ManyEditor.

When displaying a multiple selection where the objects are of different types, the Property Grid shows only those properties which exist on all the selected objects and have the same type across the selected objects. For example, suppose the selected objects are a Circle and a Line. The grid might display a Line Color property because it exists on both Circles and Lines, but not a Fill property because that exists only on Circle. Similarly, if the selected objects are a Circle and a BigCircle, and Circle.Radius is an int, but BigCircle.Radius is a long, the grid would not display the Radius property.

Custom Editors and Multiple Selection

If you want are declaring editors in a multiple selection scenario, the following considerations apply: